﻿Imports DTO
Imports System.Data.SqlClient
Public Class CPhieuTraDAO
    Public Function ThemPhieuTra(ByRef _phieutra As CPhieuTraDTO) As Integer
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspThemPhieuTra", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As SqlParameter = New SqlParameter("@ngaytra", _phieutra.NgayTra)
            cm.Parameters.Add(para)
            para = New SqlParameter("@madocgia", _phieutra.MaDocGia)
            cm.Parameters.Add(para)
            para = New SqlParameter("@tienphatkynay", _phieutra.TienPhatKyNay)
            cm.Parameters.Add(para)
            para = New SqlParameter("@tienno", _phieutra.TienNo)
            cm.Parameters.Add(para)
            para = New SqlParameter("@tongno", _phieutra.TongNo)
            cm.Parameters.Add(para)
            para = New SqlParameter("@ma", _phieutra.Ma)
            para.Direction = ParameterDirection.Output
            cm.Parameters.Add(para)
            Dim n As Integer = cm.ExecuteNonQuery()
            cn.Close()
            _phieutra.Ma = cm.Parameters("@ma").Value
            Return n
        End Using
    End Function
End Class
